package controlGraph;

import java.util.ArrayList;
import java.util.Iterator;

public class ArrayArith {
	
	private ArrayList<ArithExpr> array = null;
	
	/**
	 * Public Constructor
	 */
	public ArrayArith(){
		this.array = new ArrayList<ArithExpr> ();
	}
	
	/**
	 * Constructor creates a new separate Copy
	 * @param source - The source
	 */
	public ArrayArith(ArrayArith source){
		
		ArrayList<ArithExpr> temp = source.getArrays();
		
		if(temp == null){
			this.array = null;
		}
		else{
			this.array = new ArrayList<ArithExpr> (source.getArrays());
		}
	}
	
	/**
	 * @return - Return the ArithExpr array
	 */
	public ArrayList<ArithExpr> getArrays(){
		return this.array;
	}
	
	/**
	 * @param e - Adds the ArithExpr expression e to the array
	 */
	public void addArith(ArithExpr e){
			this.array.add(e);
	}
	
	public void removeArith(Expression e){
		ArrayList<ArithExpr> temp = new ArrayList<ArithExpr>();
		
		Iterator<ArithExpr> it = this.array.iterator();
		while(it.hasNext()){
			ArithExpr current = it.next();
			if(current.canRemove(e)){
				continue;
			}
			temp.add(current);
		}//end - while(it.hasNext())		
		this.array = temp;
	}
	
}
